package LuoGu.贪心.摘苹果;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int S = s.nextInt();
        int a = s.nextInt();
        int b = s.nextInt();
        a += b;
        int [][] temp = new int [n][2];
        for(int i=0;i<n;i++){
            temp[i][0] = s.nextInt();
            temp[i][1] = s.nextInt();
        }
        Arrays.sort(temp, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                if(o1[1]==o2[1]) return o1[0]-o2[0];
                else return o1[1]-o2[1];
            }
        });
        int ans = 0;
        for(int i=0;i<n;i++){
            if(a>=temp[i][0]){
                ans++;
                S-=temp[i][1];
            }
            if(S<0){
                ans--;
                break;
            }
        }
        System.out.print(ans);
    }
}
